RT_SECURE_NO_WARNINGS 1

//#include<iostream>
//#include<vector>
//
//using namespace std;
//
//int main()
//{
//	vector<int> b{ 1,2,63};
//
//	auto it = b.begin();
//
//	std::cout << *it << std::endl;
//
//	return 0;
//}


#include<iostream>
#include<vector>

using namespace std;

void Shuffle(vector<int>& left, vector<int>& right, vector<int>& ret, int k, int n)
{
    while (k--)
    {
        //洗牌
        auto Itleft = left.begin();
        auto Itright = right.begin();
        for (int i = 0; i < 2 * n; i++)
        {
            if (i % 2 != 0)
            {
                ret[i] = *Itright;
                Itright++;
            }
            else
            {
                ret[i] = *Itleft;
                Itleft++;
            }
        }

        //改变left和right原有数据
        left.clear();
        right.clear();
        for (int i = 0; i < n; i++)
        {
            left.push_back(ret[i]);
        }
        for (int i = 0; i < n; i++)
        {
            right.push_back(ret[i + n]);
        }
    }
}

int main()
{
    int T = 0;//有T轮
    int n = 0;//总共有2n张牌
    int k = 0;//洗牌次数
    vector<int> left;
    vector<int> right;
    vector<int> ret;
    cin >> T;
    while (T--)
    {
        cin >> n >> k;
        int tmp;
        left.resize(n);
        right.resize(n);
        ret.resize(2 * n);
        for (int i = 0; i < n; i++)
        {
            cin >> left[i];
        }
        for (int i = 0; i < n; i++)
        {
            cin >> right[i];
        }

        Shuffle(left, right, ret, k, n);
        for (auto e : ret)
        {
            cout << e << " ";
        }
        cout << endl;
    }
    return 0;
}
